//
//  IDMViewController.m
//  Methods
//
//  Created by iD Student on 7/10/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "IDMViewController.h"

@interface IDMViewController ()

@end

@implementation IDMViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (int)getScore
{
    return score;
}

- (void)addToScore
{
    score+= 10;
}

- (void)gameOver:(int)winner
{
    if(winner == 1)
    {
        [self updateLabel:winnerLabel withText:@"Player 1 Wins!"];
    }
    else if(winner == 2)
    {
        [self updateLabel:winnerLabel withText:@"Player 2 Wins!"];
    }
}

- (void) updateLabel:(UILabel *)label withText:(NSString *)text
{
    label.text = text;
}

- (IBAction)player1Click:(id)sender
{
    [self addToScore];
    int playerScore = [self getScore];
    if (playerScore >= 100)
    {
        [self gameOver:1];
    }
}


- (void)gameOver
{
    int playerScore = [self getScore];
    if (playerScore > 10) {
        winnerLabel.text = @"Good Score!";
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [winnerLabel release];
    [super dealloc];
}
@end
